<style>
    .setimg {
        margin: -2px 5px 0 0
    }
</style>
<div class="row-fluid">
    <a style="border:1px solid #ccc" class="block-heading" data-toggle="collapse">列表数据</a>
    <div class="well">
        <div class="btn-toolbar">
            <button class="btn btn-primary ifrm" data-url="/hospital/addHospt" data-width="780" data-height="500"
                    data-title="添加机构" data-params="" style="float:right;padding:3px 6px">添加医院
            </button>
            <form>
                <label style="display: inline;">医院名称：</label>
                <input class="input input-medium" type="text" name="hos_name" value="<?=I('get.hos_name')?>"/>
                <input type="hidden" value="<?=I('get.res')?>" name="res"/>
                <button class="btn btn-info" style="margin:-9px 0 0 15px"><i class="icon-search"></i> 搜索</button>
            </form>
        </div>
        <hr>
        <table class="table">
            <thead>
            <tr>
                <th style="text-align:center">ID</th>
                <th style="text-align:center">主体编码</th>
                <th style="text-align:center">医院名称</th>
                <th style="text-align:center">类型</th>
                <th style="text-align:center">省市</th>
                <th style="text-align:center">联系人</th>
                <th style="text-align:center">手机号</th>
                <th style="text-align:center">营业执照登记号</th>
                <th style="text-align:center">添加时间</th>
                <th style="text-align:center">操作</th>
            </tr>
            </thead>
            <tbody>
            <?php if($newsList){foreach($newsList AS $key=>$val){ ?>
            <tr class="tr">
                <td style="text-align:center;vertical-align:middle"><?=$val['id']?></td>
                <td style="text-align:center;vertical-align:middle"><?=$val['main_code']?></td>
                <td style="text-align:center;vertical-align:middle"><?=$val['hos_name']?></td>
                <td style="text-align:center;vertical-align:middle"><?=$val['hos_type']?></td>
                <td style="text-align:center;vertical-align:middle"><?=$val['province']?>-<?=$val['city']?></td>
                <td style="text-align:center;vertical-align:middle"><?=$val['contact_person']?></td>
                <td style="text-align:center;vertical-align:middle"><?=$val['mobile']?></td>
                <td style="text-align:center;vertical-align:middle"><?=$val['agency_number']?></td>
                <td style="text-align:center;vertical-align:middle"><?=date('Y-m-d',$val['add_at'])?></td>
                <td style="text-align:center;vertical-align:middle">

                    <a class="ifrm btn btn-info" href="javascript:void(0)" data-url="/hospital/addHospt" data-width="780"
                       data-height="500" data-title="修改机构信息" data-params="id/<?=$val['id']?>"
                       style="padding: 0px 4px;"><i class="icon-pencil"></i></a>&nbsp;&nbsp;
                    <a style="padding: 0px 4px;" href="/hospital/deleteHospt?hospt_id=<?=$val['hospt_id']?>"
                       class="decate btn btn-danger" data-cateid="<?=$val['hospt_id']?>" role="button"
                       data-toggle="modal"><i class="icon-remove"></i></a>&nbsp;&nbsp;

                </td>
            </tr>
            <?php }}?>
            </tbody>
        </table>
        <span style="float:right;margin-top:-44px"><?=$page?></span>
    </div>
</div>
<script>
    $(function () {
        $('.decate').live('click', function () {
            if (!window.confirm('确定删除该文章 ?')) {
                return false;
            }
            window.location = $(this).attr('href');
        });

        $('.setrecommend').on('click',function(){
            id = $(this).attr('data-id');
            rec= $(this).attr('data-recommend');
            _this = $(this);
            $.ajax({
                url: '/hospital/setRecommend',
                type: 'POST',
                dataType: 'json',
                data: {'id': id,'rec':rec},
            })
            .done(function(d) {
                if(d.code == 0){
                    showmsg(d.msg,1);
                    if(_this.children().hasClass('icon-star')){
                        _this.attr('data-recommend',0);
                        _this.children().removeClass('icon-star');
                       _this.children().addClass('icon-star-empty');
                    }else{
                        _this.attr('data-recommend',1);
                        _this.children().removeClass('icon-star-empty');
                        _this.children().addClass('icon-star');
                    }
                }else{
                    showmsg(d.msg,0);
                }        
            })       
        })
    })
</script>